/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-11-29 17:22:04
 * @LastEditors: huangtianyang
 * @LastEditTime: 2024-01-18 17:02:11
 * @FilePath: \cxl-driving-training\src\apis\trainSite\index.ts
 */
import axios from '../../axios/index'

export interface trainSiteOperationInterface {
    addressDetail?: string //详细地址
    equipmentIntroduction?: string //设备介绍
    id?: string
    lat?: string //维度
    lng?: string //经度
    name?: string
    openHours?: string //场地开放时间
    ownFlag?: number //是否自有(0.否；1.是)
    regionId?: string //区id
    siteCategory?: number //场地类别（2.科目二；3.科目三）
    siteIntroduction?: string
    sitePicList?: string[]
    siteType?: number //场地类型
    supportFacilitys?: { name: string; pic: string }[]
}

export const trainSiteAdd = (data: trainSiteOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSite/add',
        data
    })
}

export const trainSiteEdit = (data: trainSiteOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSite/edit',
        data
    })
}

export const trainSiteDetailed = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSite/detailById',
        params: { id }
    })
}

export interface trainSiteListInterface {
    current?: number
    size?: number
    addressDetail?: string
    disable?: number //0.可用；1.禁用
    name?: string
    ownFlag?: number //是否自有(0.否；1.是)
    siteType?: number //场地类型
    siteCategory?: number //场地类别（2.科目二；3.科目三）
}

export const trainSiteList = (params: trainSiteListInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSite/pageList',
        params
    })
}

//导入科目三场地
export const importSiteThree = (file: File) => {
    const fileFormData = new FormData()
    fileFormData.append('file', file)
    return axios({
        method: 'post',
        url: '/api/system/trainSite/importSiteThreeExcel',
        data: fileFormData
    })
}

//导入科目二场地
export const importSiteTwo = (file: File) => {
    const fileFormData = new FormData()
    fileFormData.append('file', file)
    return axios({
        method: 'post',
        url: '/api/system/trainSite/importSiteTwoExcel',
        data: fileFormData
    })
}

//场地分页选择器
export const siteSearchSelete = (params: trainSiteListInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSite/siteSelect',
        params
    })
}

/**
 * 场地禁用启用
 * @param disable  0.可用；1.禁用
 * @param id
 * @returns
 */
export const siteDisable = (disable: number, id: string) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSite/enable',
        data: { disable, id }
    })
}
